import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ConfigService } from './config.service';
import { Singlepage } from '../model/singlepage';

@Injectable()
export class SinglepageService {

  constructor(
    private http:HttpClient,
    private config:ConfigService
  ) { }


  private  getSinglepageListUrl=this.config.host+"/manage/getSinglepageList";

  getSinglepageList(){
    return this.http.get(this.getSinglepageListUrl).toPromise();
  }

  addSinglepageUrl=this.config.host+"/manage/addSinglepage";
  addSinglepage(singlepage:Singlepage){
    let p={
  "singlepageid":singlepage.singlepageid,
  "img":singlepage.img,
  "title":singlepage.title,
  "summary":singlepage.summary,
    }
    return this.http.post(this.addSinglepageUrl,p).toPromise();
  }

  private deleteSinglepagelUrl=this.config.host+"/manage/deleteSinglepage";
  deleteSinglepage(id:string){
  let p={
    "singlepageid":id
  }
  return this.http.post(this.deleteSinglepagelUrl,p).toPromise();
}


private getSinglepagelUrl=this.config.host+"/manage/getSinglepage";
getSinglepage(id:string){
  let p={
    "singlepageid":id
  }
  return this.http.post(this.getSinglepagelUrl,p).toPromise();
}


private updateSinglepagelUrl=this.config.host+"/manage/updateSinglepage";
updateSinglepage(singlepage:Singlepage){
  let p={
      "singlepageid":singlepage.singlepageid,
      "img":singlepage.img,
      "title":singlepage.title,
      "summary":singlepage.summary,
  }
  return this.http.post(this.updateSinglepagelUrl,p).toPromise();
}



}
